/* 
 * File:   memory.h
 * Author: bjorn
 *
 * Created on September 2, 2007, 11:22 AM
 */

#ifndef _MEMORY_H
#define	_MEMORY_H

#include <stdlib.h>    
    
typedef void *  eruta_pointer;    
typedef void ** eruta_pointer_pointer;    
    
extern void * memory_allocate(size_t size);
extern void   memory_free(void * pointer);
extern void * memory_realloc(void * pointer, size_t size);    

#define memory_make(type)     			memory_allocate(sizeof(type))     

#define eruta_allocate(size) 			memory_allocate(size)
#define eruta_free(pointer)				memory_free(pointer)
#define eruta_realloc(pointer, size) 	memory_realloc(pointer, size)

#define eruta_struct_make(type)     (struct type *) eruta_allocate(sizeof(struct type))     
#define eruta_struct_name(type)     (type##_struct)    
#define eruta_struct_wrap(type)     (struct type##_struct)        
#define eruta_struct_ptr(type)      (struct type##_struct *)    
#define eruta_struct_size(type)     (sizeof(struct type##_struct))        
#define eruta_make(type)            (eruta_struct_ptr(type) eruta_allocate(eruta_struct_size(type))) 
   


#endif	/* _MEMORY_H */

